﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Youshow.Ace.AspNetCore.Jwt;

namespace RBACDemo.Web.Controllers;

public class NewApiController(
    IJwtManager jwtManager) : BaseController
{
    /// <summary>
    /// 获取用户姓名
    /// </summary>
    /// <param name="userName"></param>
    /// <returns></returns>
    [Authorize(AceJwtPolicyDefault.AUTHORIZATION_POLICY)]
    [HttpGet]
    public async Task<string> GetUserName(string userName)
    {
        return userName;
    }

    [HttpGet("jwt")]
    public async Task<string> GetUserToken(long userId)
    {
        return jwtManager.CreateToken(new ModelClaimValue<long>(userId));
    }
}